<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
    <title>月度意见名称初始化</title>
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/weui.min.css')}}">
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/jquery-weui.css')}}">
    <link rel="stylesheet" href="{{asset('/css/system/iconfont.css')}}">
    <link rel="stylesheet" href="{{asset('/css/system/common.css')}}">
    <link rel="stylesheet" href="{{asset('/css/system/authority-manage.css')}}">
    @include('sysadmin.head')
</head>
<style>
    .opinion-init{
       background-color: #fff;
        padding: 20px 10px;

    }
    .opinion-init-con{
        margin-bottom: 30px;

    }
    .opinion-init .input{
        width: 100px;
        border: 1px solid #ddd;
        height: 28px;
        border-radius: 15px;
        text-align: center;
        float: left;
        margin-bottom: 10px;
        margin-left: 10px;
    }
    .opinion-init input{
        width: 68px;
        border: none;
        height: 24px;
        margin-left: 2px;
        text-align: center;
    }
    i.icon-shanchu3.dn{
        display: none;
    }
</style>
<body ontouchstart>
<div class="weui-cell" style="background-color: #fff;border-bottom: 1px solid #ececec; line-height: 40px;">
    <div class="weui-cell__bd">
        <p>月度意见名称初始化(至少五项，保存后不可修改)：</p>
    </div>

</div>
<div class="opinion-init">
    <div class="opinion-init-con">
        <div class="weui-flex">
            <div class="weui-flex__item pr">
                <div class="input">
                    <input type="text" class="input-score" name="opinion-name[]" value="主动性">
                    <i class="icon iconfont icon-shanchu3 dn"></i>
                </div>
                <div class="input">
                    <input type="text" class="input-score" name="opinion-name[]" value="学习能力">
                    <i class="icon iconfont icon-shanchu3 dn"></i>
                </div>
                <div class="input">
                    <input type="text" class="input-score" name="opinion-name[]" value="合作精神">
                    <i class="icon iconfont icon-shanchu3 dn"></i>
                </div>
                <div class="input">
                    <input type="text" class="input-score" name="opinion-name[]" value="技能">
                    <i class="icon iconfont icon-shanchu3 dn"></i>
                </div>
                <div class="input opinion-add" style="background-color: #65B6B1;">
                    <a href="javascript:;" class="btn-submit  weui-btn_color " >
                        添加
                        <i class="weui-icon-add"></i>
                    </a>
                </div>


                {!! csrf_field() !!}
            </div>
        </div>


    </div>
    <div style="margin: 0 30px;">
        <a href="javascript:;" class="btn-submit weui-btn weui-btn_color save-opinion">保存</a>
    </div>
    <div style="margin: 10px 30px;">
        <a href="javascript:;" style="background-color: #ff6666;" class="btn-submit weui-btn weui-btn_color del-opinion">删除</a>
    </div>
</div>

<div class="mian-container">

    <!--阴影遮罩-->
    <div class="list-shadow"></div>
    <!-- 隐藏考核按钮部分-->
    @include('sysadmin.admin-caidan')
</div>
<script src="{{asset('/kaohe/js/jquery-2.1.4.min.js')}}"></script>
<script src="{{asset('/addons/jquery-weui-build/js/fastclick.js')}}"></script>
<script>
    $(function() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        FastClick.attach(document.body);
    });
</script>
<script src="{{asset('/addons/jquery-weui-build/js/jquery-weui.min.js')}}"></script>
<script>
    $(document).ready(function () {
        $('.kaohe-item').click(function(){
            $('.show-hidden').toggle();
        });
        $('.admin-item').click(function(){
            $('.front-show-hidden').toggle();
        });
    });
    $(".sex").picker({
        title: "请选择性别",
        cols: [
            {
                textAlign: 'center',
                values: ['男', '女']
            }
        ]
    });
    $('.opinion-add').click(function(){
        $(this).parent().prepend('<div class="input"> <input type="text" class="input-score" name="opinion-name[]" value="" placeholder="请填写"> <i class="icon iconfont icon-shanchu3 dn"></i> </div>');
    });
    $('.del-opinion').click(function(){
        $('.icon-shanchu3').toggleClass('dn');
    });
    $('.icon-shanchu3').click(function(){
        $(this).parent().remove();
    });
    //提交
    $('.save-opinion').click(function(){
        var token = $('input[name=_token]').val();
        var pids = [];
        $('input[name="opinion-name[]"]').each(function () {
            if($(this).val().length > 7){
                $.toast("名称不能超过7个字符", "text");
                return false;
            }
            if($(this).val().length == 0){
                $.toast("不能有空值", "text");
                return false;
            }
            pids.push($(this).val());
        });
        if(pids.length < 5){
            $.toast("名称至少要填写五项", "text");
            return false;
        }
        //console.log(pids);
        $.ajax({
            'url': '/sysadmin/feedback/init-feedback?_token='+token,
            'type': 'POST',
            'data': {'name':JSON.stringify(pids)},
            error: function (request) {
                $.toast('网络错误',"text");
            },
            success: function (data) {
                if (data.status == 'success') {
                    $.toast("操作成功");
                    window.location.href='/sysadmin/feedback/feedback';
                } else {
                    $.toast(data.msg,"text");
                }
            },
        });
    });
</script>
</body>
</html>